import com.vhly.util.DeviceInfo;

import javax.microedition.lcdui.Graphics;

final class cls_n extends cls_w {

    private int c;
    private int d;
    int a;
    private cls_u e;
    cls_k fld_b_k;
    private static int f[][] = {
            {
                    38, 8, -1
            }, {
                    38, 12, -1
            }, {
                    38, 9, 0
            }, {
                    38, 7, -1
            }, {
                    38, 4, 0
            }, {
                    38, 12, -1
            }, {
                    38, 8, 0
            }, {
                    38, 4, 0
            }, {
                    38, 12, 0
            }, {
                    38, 0, -1
            }, {
                    40, 4, 0
            }, {
                    40, 12, -1
            }, {
                    38, 6, 0
            }, {
                    38, 10, 0
            }, {
                    38, 2, 0
            }, {
                    38, 14, -1
            }, {
                    38, 7, 0
            }, {
                    38, 8, 0
            }, {
                    38, 9, -1
            }, {
                    39, 4, -1
            }, {
                    38, 8, -1
            }, {
                    41, 6, -1
            }, {
                    41, 10, -1
            }, {
                    41, 2, -1
            }, {
                    41, 14, -1
            }, {
                    38, 0, -1
            }, {
                    39, 12, -1
            }, {
                    38, 7, 0
            }, {
                    38, 0, 0
            }, {
                    38, 9, -1
            }, {
                    41, 8, 0
            }, {
                    41, 4, 0
            }, {
                    41, 12, 0
            }, {
                    41, 0, -1
            }, {
                    38, 1, 0
            }, {
                    38, 0, 0
            }, {
                    38, 15, -1
            }
    };

    public cls_n(MainThread thread) {
        super(thread);
        super.K = 25;
        super.L = 27;
        e = new cls_u(111, 70);
        e.l = 90;
        fld_b_k = new cls_k(99, 4);
        c = 0;
        d = (thread.T >> 2) + 1;
        I.b[25] = new cls_h(mainThread, (short) 161, new short[]{
                252, 182, 186, 187, 188, 241, 242
        }, (short) 5, (short) 6, 4);
        I.b[26] = new cls_h(mainThread, (short) 253, new short[]{
                255, 0
        }, (short) 5, (short) 4, 9);
        I.b[26].a((short) 254);
        super.am[0] = (new short[]{
                236
        });
    }

    final void b(int i, int j) {
        if ((i & 0x20000) != 0 || (i & 0x1020) != 0) {
            if (super.I.a.fld_b_int == 9 && (i & 0x1000) != 0) {
                super.I.a.c(i);
                return;
            }
//            cls_ae aei;
            switch (j) {
                case 25: // '\031'
                    super.J.b(25);
                    if (super.mainThread.aq >= 0) {
                        System.arraycopy(super.mainThread.recordManager.v.toCharArray(), 0, super.I.b[26].B[0], 0, super.mainThread.recordManager.v.length());
                        j = 26;
//                        aei = super.I;
                        super.I.a(j, false);
                        return;
                    } else {
                        j = 13;
//                        aei = super.I;
                        super.I.a(j, false);
                        super.I.a.fld_q_short = 5;
                        super.I.a.r = 6;
                        return;
                    }

                case 26: // '\032'
                    super.mainThread.recordManager.v = (new String(super.I.b[26].B[0])).trim();
                    super.mainThread.recordManager.o[super.mainThread.aq] = super.mainThread.recordManager.v;
                    super.mainThread.recordManager.saveStats();
                    super.I.a(13);
                    super.I.a.fld_q_short = 5;
                    super.I.a.r = 6;
                    return;
            }
            super.b(i, j);
            return;
        }
        if ((i & 0x40000) != 0 || (i & 0x40) != 0)
            switch (j) {
                case 25: // '\031'
                    if ((i & 0x40) != 0) {
                        super.J.b(25);
                        if (super.mainThread.aq >= 0) {
                            System.arraycopy(super.mainThread.recordManager.v.toCharArray(), 0, super.I.b[26].B[0], 0, super.mainThread.recordManager.v.length());
                            super.I.a(26);
                            return;
                        } else {
                            super.I.a(13);
                            super.I.a.fld_q_short = 5;
                            super.I.a.r = 6;
                            return;
                        }
                    }
                    break;

                case 13:
                    if (super.I.a.r == 4) {
                        super.I.e();
                        return;
                    }
                    if ((i & 0x40) != 0) {
                        super.mainThread.k(4);
                        return;
                    }
                    break;

                default:
                    super.b(i, j);
                    return;
            }
        else
            super.b(i, j);
    }

    final void b_(int i) {
        super.b_(i);
        if (i == 9) {
            super.mainThread.c();
            a();
        }
    }

    final void d(int i) {
        super.d(i);
        switch (i) {
            case 10:
            case 11: // '\013'
            default:
                break;

            case 13:
                if (super.mainThread.aq == 0) {
                    super.mainThread.recordManager.a(5, (int) super.mainThread.bR, -1);
                    super.mainThread.recordManager.a(0, super.mainThread.T + 1, -1);
                    super.mainThread.aq = super.mainThread.recordManager.a(super.mainThread.recordManager.l[6], super.mainThread.R);
                    super.mainThread.recordManager.saveStats();
                    super.mainThread.recordManager.savePrefs();
                    return;
                }
                break;

            case 9:
                super.mainThread.L.d();
                e.m = 0L;
                super.mainThread.cF = super.mainThread.bR + 1000L;
                super.mainThread.ar = super.mainThread.recordManager.l[6] = super.mainThread.recordManager.g;
                super.mainThread.ck.a();
                return;

            case 12: // '\f'
                super.mainThread.fld_m_Vector.removeAllElements();
                super.mainThread.k();
                super.mainThread.recordManager.a(5, (int) super.mainThread.bR, -1);
                for (i = 0; i < super.mainThread.ch.length; i++) {
                    super.mainThread.cf[i] = super.mainThread.ch[i] - super.mainThread.cg[i];
                    super.mainThread.ce[i] = 0;
                    super.mainThread.cg[i] = super.mainThread.ch[i];
                }

                super.mainThread.recordManager.e = super.mainThread.T + 1;
                super.mainThread.recordManager.f = 17 - super.mainThread.ck.F;
                super.mainThread.recordManager.g = super.mainThread.recordManager.l[6];
                super.mainThread.recordManager.saveStats();
                super.mainThread.cB = super.mainThread.strs[124] + Integer.toString(super.mainThread.T + 1) + super.mainThread.strs[125];
                super.mainThread.recordManager.savePrefs();
                break;
        }
    }

    final void a() {
        int j2;
        cls_d d1 = new cls_d(super.mainThread, 42, 20 + super.mainThread.j(((45056) >> 8) - 40), 30 + super.mainThread.j(((47616) >> 8) - 40));
        super.mainThread.fld_m_Vector.addElement(d1);
        int i;
        i = (i = super.mainThread.ck.E + d1.E << 1) * i;
        do {
            int k2;
            int l = (d1.o.a - super.mainThread.ck.o.a) >> 8;
            int j1 = (d1.o.b - super.mainThread.ck.o.b) >> 8;
            int l1;
            if ((l * l + j1 * j1) >= i)
                break;
            d1.o = new cls_aa(20 + super.mainThread.j(((45056) >> 8) - 40), 30 + super.mainThread.j(((47616) >> 8) - 40));
        } while (true);
        if (super.mainThread.bU < super.mainThread.bR)
            super.mainThread.cF = super.mainThread.cF + super.mainThread.bR >> 1;
        boolean flag = false;
        for (int k1 = 0; k1 < super.mainThread.fld_m_Vector.size(); k1++) {
//            cls_d d3;
            if (((cls_d) super.mainThread.fld_m_Vector.elementAt(k1)).s == 24)
                flag = true;
        }

        if (super.mainThread.T >= 2 && super.mainThread.j(super.mainThread.T >> 1) == 0 && !flag) {
            byte byte0;
            switch (super.mainThread.j(7)) {
                case 0:
                    byte0 = 43;
                    break;

                case 1:
                    byte0 = 44;
                    break;

                case 2:
                    byte0 = 45;
                    break;

                case 3:
                    byte0 = 46;
                    break;

                case 4:
                    byte0 = 47;
                    break;

                case 5:
                    byte0 = 48;
                    break;

                default:
                    byte0 = 49;
                    break;
            }
            cls_d d2;
            int l2;
            (d2 = new cls_d(super.mainThread, byte0, 20 + super.mainThread.j(((45056) >> 8) - 40), 30 + super.mainThread.j(((47616) >> 8) - 40))).h = super.mainThread.bk[byte0 - 43];
            d2.T = e;
            super.mainThread.fld_m_Vector.addElement(d2);
            int j;
            j = (j = super.mainThread.ck.E + d2.E << 1) * j;
            do {
                int i3;
                int i2 = (d2.o.a - super.mainThread.ck.o.a) >> 8;
                int i1 = (d2.o.b - super.mainThread.ck.o.b) >> 8;
                if ((i2 * i2 + i1 * i1) >= j)
                    break;
                d2.o = new cls_aa(20 + super.mainThread.j(((45056) >> 8) - 40), 30 + super.mainThread.j(((47616) >> 8) - 40));
            } while (true);
        }
        super.mainThread.cn = super.mainThread.ck;
        super.mainThread.A = false;
    }

    final void a(int i) {
        e = null;
        fld_b_k = null;
    }

    final void a(int i, int j) {
        if (super.mainThread.B)
            return;
        if ((i & 0x1020) != 0 && super.mainThread.cr != -1) {
            if (mainThread.cr == 0) {
                int l = 14;
//                cls_ab ab1 = J;
                J.a(l, false);
                l = 70 - mainThread.T;
                int j1 = mainThread.fld_m_Vector.size();
                for (int l1 = 1; l1 < j1; l1++) {
                    cls_d d3;
                    if (((d3 = (cls_d) mainThread.fld_m_Vector.elementAt(l1)).H & 0x2000) != 0)
                        continue;
//                    int j4;
                    int l2 = (mainThread.ck.o.a - d3.o.a) >> 8;
                    int j3 = (mainThread.ck.o.b - d3.o.b) >> 8;
//                    int l3;
                    if ((l2 * l2 + j3 * j3) < l * l)
                        d3.j = 1;
                }

                int i2 = 8;
                int k2 = 192;
                int i3 = 16;
                do {
                    int k3;
                    if (k2 > 0 && k2 < 128)
                        k3 = 16;
                    else if (k2 == 0 || k2 == 128)
                        k3 = 2;
                    else
                        k3 = 32;
                    if (k2 > 64 && k2 < 192)
                        k3 |= 8;
                    else if (k2 == 64 || k2 == 192)
                        k3 |= 1;
                    else
                        k3 |= 4;
                    int i4 = MainThread.g(k2);
                    int k1 = MainThread.f(k2);
                    cls_u u1;
                    (u1 = new cls_u(mainThread.bb)).j = 0;
                    u1.b = i2 >= 16 ? i2 - 16 : i2;
//                    int k4;
                    u1.n = new cls_aa((mainThread.ck.o.a - mainThread.ci.a) >> 8, (mainThread.ck.o.b - mainThread.ci.b) >> 8);
                    u1.n.a(((mainThread.ck.o.a - mainThread.ci.a) + l * i4 + 128) >> 8, ((mainThread.ck.o.b - mainThread.ci.b) + l * k1 + 128) >> 8, 5);
                    u1.h = k3;
                    vector.addElement(u1);
                    k2 += 16;
                    i2++;
                } while (--i3 > 0);
            } else if (mainThread.cr == 1) {
                byte byte0 = 20;
//                cls_ab ab2 = J;
                J.a(byte0, false);
                mainThread.bU = mainThread.bR + 7000L;
            } else if (mainThread.cr == 2) {
                byte byte1 = 22;
//                cls_ab ab3 = J;
                J.a(byte1, false);
                mainThread.bV = mainThread.bR + 5000L;
                for (int i1 = 0; i1 < 256; i1 += 16)
                    mainThread.ck.a(0, 32768, i1, 1);

            } else if (mainThread.cr == 3) {
                byte byte2 = 11;
//                cls_ab ab4 = J;
                J.a(byte2, false);
                mainThread.bW = mainThread.bR + 7000L;
                if (mainThread.ck.D == 0) {
                    mainThread.ck.D = mainThread.ck.B;
                    mainThread.ck.B = mainThread.ck.B >> 2;
                    mainThread.ck.a();
                    mainThread.ck.M[11] = 1500L + mainThread.bR;
                    mainThread.ck.I = -1;
                }
            } else if (mainThread.cr == 4) {
                byte byte3 = 19;
//                cls_ab ab5 = J;
                J.a(byte3, false);
                mainThread.bX = mainThread.bR + 3000L;
            } else if (mainThread.cr == 5)
                mainThread.ck.H |= 0x10000;
            else if (mainThread.cr == 6) {
                cls_d d1 = mainThread.ck;
                int j2 = 100;
                mainThread.o.removeAllElements();
                do {
                    cls_d d2;
                    if ((d2 = mainThread.b(d1, j2 * j2, 33)) == null)
                        break;
                    mainThread.o.addElement(d2.o);
                    d2.b(1, 3000);
                    d2.j = 1;
                    d1 = d2;
                } while ((j2 -= 5) > 0);
                if (mainThread.o.size() > 0) {
                    mainThread.o.insertElementAt(mainThread.ck.o, 0);
                    mainThread.bY = mainThread.bR + 1000L;
                    mainThread.ck.Q = mainThread.bR + 10000L;
                    byte byte4 = 16;
//                    cls_ab ab6 = J;
                    J.a(byte4, false);
                }
                mainThread.bG.b = 0;
                mainThread.bG.a(0, mainThread.bG.e);
            }
            super.mainThread.cr = -1;
        }
        if ((j & 0x100) != 0)
            j |= 0xa0a;
        else if ((j & 0x400) != 0)
            j |= 0x2212;
        else if ((j & 0x4000) != 0)
            j |= 0x880c;
        else if ((j & 0x10000) != 0)
            j |= 0xa014;
        if ((j & 0x202) != 0) {
            if ((j & 0x2010) != 0)
                super.mainThread.ck.fld_m_int = 224;
            else if ((j & 0x808) != 0)
                super.mainThread.ck.fld_m_int = 160;
            else
                super.mainThread.ck.fld_m_int = 192;
        } else if ((j & 0x2010) != 0) {
            if ((j & 0x8004) != 0)
                super.mainThread.ck.fld_m_int = 32;
            else
                super.mainThread.ck.fld_m_int = 0;
        } else if ((j & 0x8004) != 0) {
            if ((j & 0x808) != 0)
                super.mainThread.ck.fld_m_int = 96;
            else
                super.mainThread.ck.fld_m_int = 64;
        } else if ((j & 0x808) != 0)
            super.mainThread.ck.fld_m_int = 128;
        if ((j & 0x1ef1e) != 0)
            super.mainThread.ck.d = super.mainThread.ck.e;
        else if (super.mainThread.ck.d > 2) {
            super.mainThread.ck.b();
            super.mainThread.ck.b();
            super.mainThread.ck.b();
        }
        super.mainThread.ck.l = super.mainThread.ck.fld_m_int;
    }

    final void a(int ai[]) {
        b(ai);
        super.ak = null;
    }

    final void b() {
        if (super.mainThread.ck.F > 0) {
            if (super.mainThread.cF < super.mainThread.bR) {
                cls_n n1;
                if ((n1 = this).c >= f.length)
                    n1.c = 0;
                long l;
                do {
                    l = f[n1.c][0];
                    cls_d d1 = new cls_d(n1.mainThread, (int) l, 0, 0);
                    (d1).d = d1.e;
                    switch (f[n1.c][1]) {
                        case 0:
//                            int i;
                            d1.o = new cls_aa((22528) >> 8, (47616) >> 8);
                            d1.l = d1.fld_m_int = 192;
                            break;

                        case 1:
//                            int j;
                            d1.o = new cls_aa((11264) >> 8, (47616) >> 8);
                            d1.l = d1.fld_m_int = 192;
                            break;

                        case 2:
//                            int i1;
                            d1.o = new cls_aa((0) >> 8, (47616) >> 8);
                            d1.l = d1.fld_m_int = 224;
                            break;

                        case 4:
//                            char c1;
                            d1.o = new cls_aa(('\0') >> 8, ('\u5D00') >> 8);
                            d1.l = d1.fld_m_int = 0;
                            break;

                        case 6:
                            int iflag = 0;
                            d1.o = new cls_aa((iflag) >> 8, (0) >> 8);
                            d1.l = d1.fld_m_int = 32;
                            break;

                        case 7:
//                            char c2;
                            d1.o = new cls_aa(('\u2C00') >> 8, (0) >> 8);
                            d1.l = d1.fld_m_int = 64;
                            break;

                        case 8:
//                            char c3;
                            d1.o = new cls_aa(('\u5800') >> 8, (0) >> 8);
                            d1.l = d1.fld_m_int = 64;
                            break;

                        case 9:
//                            int j1;
                            d1.o = new cls_aa((33792) >> 8, (0) >> 8);
                            d1.l = d1.fld_m_int = 64;
                            break;

                        case 10:
//                            int k1;
                            d1.o = new cls_aa((45056) >> 8, (0) >> 8);
                            d1.l = d1.fld_m_int = 96;
                            break;

                        case 12: // '\f'
//                            int l1;
                            d1.o = new cls_aa((45056) >> 8, (23808) >> 8);
                            d1.l = d1.fld_m_int = 128;
                            break;

                        case 14: // '\016'
//                            int i2;
                            d1.o = new cls_aa((45056) >> 8, (47616) >> 8);
                            d1.l = d1.fld_m_int = 160;
                            break;

                        case 15:
//                            int j2;
                            d1.o = new cls_aa((33792) >> 8, (47616) >> 8);
                            d1.l = d1.fld_m_int = 192;
                            break;
                    }
                    n1.mainThread.recordManager.a(2, 1, (int) l);
                    n1.mainThread.fld_m_Vector.addElement(d1);
                    l = f[n1.c][2];
                    n1.c++;
                } while (l == 0L);
                if (--n1.d > 0) {
                    while (--n1.c > 0 && f[n1.c - 1][2] != -1) ;
                    ((cls_w) (n1)).mainThread.cF = n1.mainThread.bR + 1500L;
                } else {
                    n1.d = (n1.mainThread.T >> 2) + 1;
                    ((cls_w) (n1)).mainThread.cF = n1.mainThread.bR + 30000L;
                }
            }
        } else {
            super.mainThread.recordManager.e = 0;
            super.mainThread.recordManager.f = 0;
            super.mainThread.recordManager.g = 0;
            super.mainThread.aq = 0;
            super.mainThread.recordManager.savePrefs();
            if (super.mainThread.recordManager.b)
                super.mainThread.disp.vibrate(300);
            super.mainThread.gameState = 13;
            super.mainThread.fld_m_Vector.removeAllElements();
        }
    }

    final void c() {
        super.mainThread.an = -1;
        if (super.mainThread.T == 0 && !super.mainThread.recordManager.c && !e())
            super.mainThread.gameState = 10;
        else
            super.mainThread.gameState = 7;
        d = (super.mainThread.T >> 2) + 1;
        a = (1) << 8;
    }

    final void d() {
        if (super.mainThread.ar < super.mainThread.recordManager.l[6])
            super.mainThread.ar = super.mainThread.recordManager.l[6];
        if (super.mainThread.ca < MainThread.bP) {
            super.mainThread.gameState = 9;
            return;
        } else {
            super.mainThread.a(super.mainThread.bufferGraphics, 518);
            return;
        }
    }

    final void a(Graphics g) {
        g.drawImage(super.img1, 0, 0, 20);
        int i = Math.min((super.mainThread.ai * 100) / (6 * ((super.mainThread.T >> 1) + 1)), 100);
        a(g, i);
        i = super.mainThread.recordManager.l[6];
        if (super.mainThread.ar < i) {
            super.mainThread.ar++;
            int l = 10;
            do {
                if (l <= 0)
                    break;
                if (super.mainThread.ar + l <= i) {
                    super.mainThread.ar += l;
                    break;
                }
                l /= 10;
            } while (true);
        }
        super.mainThread.u.a(g, Integer.toString(super.mainThread.ar), 174, super.U.getHeight() + 4, 24);
        if (super.mainThread.cr != -1)
            super.mainThread.bk[super.mainThread.cr].a(g, 2, 1, super.mainThread.P % super.mainThread.bk[super.mainThread.cr].b, 20);
        int i1 = ((((((super.mainThread.ck.F) << 8) / super.mainThread.ck.G) * 100) >> 8) * super.P) / 100;
        g.setClip(DeviceInfo.DEVICE_SCREEN_WIDTH - i1 - 3, 0, i1, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        for (int j = 0; j < 5; j++)
            g.drawImage(super.U, DeviceInfo.DEVICE_SCREEN_WIDTH - (super.U.getWidth() - 1) * j - 3, super.img102.getHeight() >> 1, 10);

    }

    final void c(Graphics g) {
        for (int i = 0; i < super.vector.size(); i++) {
            cls_u u1;
            if ((u1 = (cls_u) super.vector.elementAt(i)).n.e == 1) {
                super.vector.removeElementAt(i--);
            } else {
                Graphics g1 = g;
                cls_u u2 = u1;
//                int j;
                u1.a(g1, (u2.n.a) >> 8, (u2.n.b) >> 8, u2.b, 0, u2.h);
                u1.a();
                u1.n.c();
            }
        }

    }

    final void b(Graphics g) {
        String s = super.mainThread.strs[super.am[0][super.mainThread.an]];
        s = cls_b.a(s);
        super.mainThread.u.a(g, s, 88, 104, 3);
    }

    final boolean e() {
        return ++super.mainThread.an >= super.am[0].length;
    }

}